﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Data;
using System.Data.SqlClient;

namespace QuanLyQuangCao
{
    class Connection
    {
        public static string ConnectionString
        {
            get
            {
                return "Server=thonglh;Database=QuanLyQuangCao;Integrated Security=true";
            }
        }

        public void GetData(string sqlConnection, DataSet ds, string dtName)
        {
            SqlConnection Conn = new SqlConnection(ConnectionString);
            Conn.Open();

            SqlCommand Cmd = new SqlCommand(sqlConnection, Conn);

            SqlDataAdapter da = new SqlDataAdapter();
            da.SelectCommand = Cmd;

            if (ds != null && ds.Tables.Contains(dtName))
            {
                ds.Tables[dtName].Clear();
                da.Fill(ds, dtName);
                Conn.Close();
            }
        }
    }
}
